﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


using System.IO;
using BrickBreaker.Core;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;


namespace LevelEditor
{
    public class Brick
    {
        private Texture2D texture;
        private Vector2 position;
        private Vector2 size;
        private Vector2 center;
        private Vector2 speed;
        private Vector2 direction;

        private BrickType type;
        private int hitCount;
        private int scoreValue;
        private BrickDensity density;


        public Brick()
        {
            this.texture = null;
            this.position = Vector2.Zero;
            this.size = Vector2.Zero;
            this.center = Vector2.Zero;
            this.speed = Vector2.Zero;
            this.direction = Vector2.Zero;

            this.type = BrickType.GREY;
            this.hitCount = 0;
            this.scoreValue = 0;
            this.density = BrickDensity.SOLID;
        }
        
        public Brick(Texture2D texture, BrickType type, Vector2 position)
        {
            this.texture = texture;
            this.type = type;
            this.position = position;
            this.size = new Vector2(this.texture.Width, this.texture.Height);
            this.center = position + (this.size / 2);
            this.speed = Vector2.Zero;
            this.direction = Vector2.Zero;
        }


        public  Texture2D Texture
        {
            get { return this.texture; }
            set { this.texture = value; }
        }
        
        public  Vector2 Position
        {
            get { return this.position; }
            set { this.position = value; }
        }
        
        public  Vector2 Size 
        {
            get 
            { 
                //return this.size;
                return new Vector2(this.texture.Width, this.texture.Height);
            }
            set { this.size = value; } 
        }

        public Vector2 Center
        {
            get 
            { 
                //return this.center;
                return (this.position + (this.size / 2) );
            }
            set { this.center = value; }
        }

        public Vector2 Speed
        {
            get { return this.speed; }
            set { this.speed = value; }
        }

        public Vector2 Direction
        {
            get { return this.direction; }
            set { this.direction = value; }
        }

        public BrickType Type
        {
            get { return this.type; }
            set { this.type = value; }
        }

        public int HitCount
        {
            get { return this.hitCount; }
            set { this.hitCount = value; }
        }

        public int ScoreValue
        {
            get { return this.scoreValue; }
            set { this.scoreValue = value; }
        }

        public BrickDensity Density
        {
            get { return this.density; }
            set { this.density = value; }
        }



        public void Draw(SpriteBatch spriteBatch)
        {
            if (this.texture != null)
            {
                spriteBatch.Draw(this.texture, this.position, Color.White);
            }
        }
    }
}
